<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>存款服务 - 智慧银行系统</title>
    <style>
        /* 全局样式 */
        body {
            margin: 0;
            font-family: "Microsoft YaHei", "微软雅黑";
            background-color: #f4f6f9;
            color: #333;
        }

        /* 顶部导航栏 */
        .top-nav {
            width: 95%;
            height: 80px;
            background-color: #1E90FF;
            display: flex;
            align-items: center;
            justify-content: space-between;
            color: white;
            padding: 0 30px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .top-nav .logo {
            font-size: 25px;
            font-weight: bold;
            letter-spacing: 1px;
            margin-left: 20px;
        }

        .top-nav .user {
            font-size: 16px;
        }

        .top-nav .user a {
            color: white;
            text-decoration: none;
            margin-left: 15px;
        }

        .top-nav .user a:hover {
            text-decoration: underline;
        }

        /* 页面整体布局 */
        .container {
            display: flex;
            height: calc(100vh - 60px);
        }

        /* 左侧导航栏 */
        .sidebar {
            width: 200px;
            background-color: #2F4F9D;
            color: white;
            display: flex;
            flex-direction: column;
            padding-top: 30px;
        }

        .sidebar a {
            padding: 15px 20px;
            text-decoration: none;
            color: white;
            font-size: 16px;
            display: block;
            text-align: center;
        }

        .sidebar a:hover,
        .sidebar a.active {
            background-color: #4169E1;
            border-left: 5px solid #FFD700;
        }

        /* 主体内容 */
        .main-content {
            flex: 1;
            padding: 20px 40px 40px 20px; /* 减少顶部和左侧内边距 */
        }

        .main-content h1 {
            color: #1E90FF;
            font-size: 26px;
            margin-bottom: 20px;
            margin-top: 0; /* 移除顶部外边距 */
            text-align: left; /* 左对齐标题 */
        }

        /* 存款表单样式 */
        .deposit-form {
            background-color: white;
            border-radius: 10px;
            padding: 40px;
            width: 600px;
            margin: 0 auto;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .form-group {
            margin-bottom: 25px;
        }

        .form-group label {
            display: inline-block;
            width: 120px;
            font-size: 16px;
            font-weight: bold;
            margin-right: 20px;
            text-align: right;
        }

        .form-group input {
            width: 300px;
            height: 40px;
            padding: 0 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 16px;
        }

        .form-group input:focus {
            outline: none;
            border-color: #1E90FF;
            box-shadow: 0 0 5px rgba(30, 144, 255, 0.3);
        }

        .required {
            color: red;
            margin-right: 5px;
        }

        .amount-tip {
            color: #666;
            font-size: 14px;
            margin-top: 5px;
            margin-left: 145px;
        }

        .submit-btn {
            text-align: center;
            margin-top: 40px;
        }

        .submit-btn input {
            background-color: #1E90FF;
            color: white;
            border: none;
            width: 150px;
            height: 45px;
            font-size: 18px;
            font-weight: bold;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .submit-btn input:hover {
            background-color: #0066CC;
        }

        /* 余额信息 */
        .balance-info {
            background-color: #f0f8ff;
            padding: 15px 20px;
            border-radius: 5px;
            margin-bottom: 20px;
            text-align: center;
        }

        .balance-info p {
            font-size: 18px;
            margin: 10px 0;
        }

        .balance-amount {
            color: #1E90FF;
            font-size: 24px;
            font-weight: bold;
        }

        /* 常用金额选项 */
        .quick-amounts {
            margin-left: 145px;
            margin-top: 10px;
        }

        .quick-amounts button {
            background-color: #f0f0f0;
            border: 1px solid #ddd;
            padding: 8px 15px;
            margin-right: 10px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
        }

        .quick-amounts button:hover {
            background-color: #e0e0e0;
        }

        /* 响应式布局 */
        @media (max-width: 768px) {
            .container {
                flex-direction: column;
            }

            .sidebar {
                width: 100%;
                flex-direction: row;
                justify-content: space-around;
                padding: 10px 0;
            }

            .sidebar a {
                padding: 10px;
                font-size: 14px;
            }

            .deposit-form {
                width: 100%;
                padding: 20px;
            }

            .form-group label {
                display: block;
                width: 100%;
                text-align: left;
                margin-bottom: 10px;
            }

            .form-group input {
                width: 100%;
                box-sizing: border-box;
            }

            .amount-tip, .quick-amounts {
                margin-left: 0;
            }
        }
    </style>
</head>

<body>

    <!-- 顶部导航栏 -->
    <div class="top-nav">
        <div class="logo">智慧银行系统</div>
        <div class="user" id="user-info">
            <a href="login.html">登录&nbsp&nbsp</a> |
            <a href="register.html">注册</a>
        </div>
    </div>

    <div class="container">
        <div class="sidebar">
            <a href="index.html">首页</a>
            <a href="deposit.html" class="active">存款服务</a>
            <a href="withdraw.html">取款服务</a>
            <a href="transactions.html">账户流水</a>
            <a href="profile.html">个人中心</a>
        </div>

        <div class="main-content">
            <h1>存款服务</h1>
            
            <div class="deposit-form">
                <!-- 账户余额信息 -->
                <div class="balance-info">
                    <p>当前账户余额</p>
                    <p class="balance-amount">¥ <span id="current-balance">0.00</span></p>
                </div>

                <form id="deposit-form" onsubmit="return handleDeposit(event)">
                    <!-- 卡号输入 -->
                    <div class="form-group">
                        <label for="card-number"><span class="required">*</span>银行卡号</label>
                        <input type="text" id="card-number" placeholder="请输入银行卡号" maxlength="19" required>
                    </div>

                    <!-- 存款金额 -->
                    <div class="form-group">
                        <label for="deposit-amount"><span class="required">*</span>存款金额</label>
                        <input type="number" id="deposit-amount" placeholder="请输入存款金额" min="0.01" step="0.01" required>
                        <div class="amount-tip">请输入0.01元以上的金额</div>
                        <div class="quick-amounts">
                            <button type="button" onclick="setQuickAmount(100)">100元</button>
                            <button type="button" onclick="setQuickAmount(500)">500元</button>
                            <button type="button" onclick="setQuickAmount(1000)">1000元</button>
                            <button type="button" onclick="setQuickAmount(5000)">5000元</button>
                        </div>
                    </div>

                    <!-- 存款类型 -->
                    <div class="form-group">
                        <label for="deposit-type"><span class="required">*</span>存款类型</label>
                        <select id="deposit-type" style="width: 330px; height: 40px; padding: 0 15px; border: 1px solid #ddd; border-radius: 5px; font-size: 16px;">
                            <option value="savings">活期存款</option>
                            <option value="fixed">定期存款</option>
                        </select>
                    </div>

                    <!-- 密码输入 -->
                    <div class="form-group">
                        <label for="transaction-pwd"><span class="required">*</span>交易密码</label>
                        <input type="password" id="transaction-pwd" placeholder="请输入交易密码" required>
                    </div>

                    <!-- 提交按钮 -->
                    <div class="submit-btn">
                        <input type="submit" value="确认存款">
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script>
        // 模拟登录状态，可替换为后端逻辑
        const isLoggedIn = false; // 改成 true 测试登录状态
        const username = "张三";
        const gender = " 先生";

        // // 设置用户信息
        // const userInfo = document.getElementById("user-info");
        // if (isLoggedIn) {
        //     userInfo.innerHTML = `亲爱的 ${username}${gender}`;
        //     // 设置模拟余额
        //     document.getElementById("current-balance").textContent = "10000.00";
        // } else {
        //     // 非登录状态下，提示用户登录
        //     document.getElementById("current-balance").textContent = "请先登录";
        // }

        // // 常用金额设置函数
        // function setQuickAmount(amount) {
        //     document.getElementById("deposit-amount").value = amount;
        // }

        // // 格式化卡号（每4位添加空格）
        // document.getElementById("card-number").addEventListener("input", function(e) {
        //     let value = e.target.value.replace(/\s/g, '');
        //     if (/^\d*$/.test(value)) {
        //         e.target.value = value.replace(/(\d{4})/g, '$1 ').trim();
        //     } else {
        //         e.target.value = value.substring(0, value.length - 1).replace(/(\d{4})/g, '$1 ').trim();
        //     }
        // });

        // // 存款处理函数
        // function handleDeposit(event) {
        //     event.preventDefault();
            
        //     if (!isLoggedIn) {
        //         alert("请先登录后再进行存款操作");
        //         window.location.href = "login.html";
        //         return false;
        //     }

        //     const cardNumber = document.getElementById("card-number").value.replace(/\s/g, '');
        //     const depositAmount = parseFloat(document.getElementById("deposit-amount").value);
        //     const depositType = document.getElementById("deposit-type").value;
        //     const transactionPwd = document.getElementById("transaction-pwd").value;

        //     // 表单验证
        //     if (cardNumber.length !== 16 && cardNumber.length !== 19) {
        //         alert("请输入正确的银行卡号（16位或19位）");
        //         return false;
        //     }

        //     if (isNaN(depositAmount) || depositAmount <= 0) {
        //         alert("请输入有效的存款金额");
        //         return false;
        //     }

        //     if (transactionPwd.length !== 6 || !/^\d+$/.test(transactionPwd)) {
        //         alert("交易密码必须为6位数字");
        //         return false;
        //     }

        //     // 模拟存款成功
        //     alert(`存款成功！\n卡号：${cardNumber}\n金额：¥${depositAmount.toFixed(2)}\n类型：${depositType === 'savings' ? '活期存款' : '定期存款'}`);
            
        //     // 更新模拟余额
        //     const currentBalance = parseFloat(document.getElementById("current-balance").textContent);
        //     document.getElementById("current-balance").textContent = (currentBalance + depositAmount).toFixed(2);
            
        //     // 重置表单
        //     document.getElementById("deposit-form").reset();
            
        //     return false;
        // }
    </script>

</body>

</html>